package utils

import (
	"regexp"
	"unicode"
)

func IdentifyInputType(input string) string {
	// Regular expressions for different types
	phoneRegex := regexp.MustCompile(`^(1[3-9]\d{9})$`) // Matches a Chinese phone number
	idCardRegex := regexp.MustCompile(`^\d{17}(\d|x)$`) // Matches a Chinese ID card number (last digit can be x)

	if ISAllChinese(input) {
		return "name"
	}else if phoneRegex.MatchString(input) {
		return "phone"
	} else if idCardRegex.MatchString(input) {
		return "IDCard"
	} else {
		return "unknown"
	}

}

func ISAllChinese(str string) bool  {
	for _, c := range str {
		if !unicode.Is(unicode.Scripts["Han"], c) {
			return false
		}
	}
	return true
}